package com.infosys.cabplanningdao.emp.dao.impl;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import com.infosys.cabplanning.common.domain.Address;
import com.infosys.cabplanning.common.domain.Employee;
import com.infosys.cabplanning.common.domain.Schedule;
import com.infosys.cabplanningdao.address.dao.impl.AddressRowMapper;
import com.infosys.cabplanningdao.schedule.dao.impl.ScheduleRowMapper;

public class EmployeeRowMapper implements RowMapper<Employee> {

	@Override
	public Employee mapRow(ResultSet rs, int rowNum) throws SQLException {
		System.out.println("before address");
		Address address = new AddressRowMapper().mapRow(rs, rowNum);
		System.out.println("before schedule");
		Schedule schedule = new ScheduleRowMapper().mapRow(rs, rowNum);
		System.out.println("after schedule");
		Employee emp = new Employee();
		emp.setAddress(address);
		emp.setSchedule(schedule);
		emp.setEmpId(rs.getString("emp_id"));
		return emp;
	}
}
